#ifndef __ARRAY_H__
#define __ARRAY_H__
#include <stdexcept>

template <typename T, int N>
class Array
{
private:
	T mArray[N];
public:
	Array();
	virtual ~Array();
	int length() const;
	bool set(int index, T value);
	bool get(int index, T& value);
	T& operator [] (int index);
	T operator[] (int index) const;
};

template <typename T, int N>
Array<T, N>::Array()
{
	for (int i = 0; i < N; i++)
		mArray[i] = i;
}

template <typename T, int N>
Array<T, N>::~Array()
{

}

template <typename T, int N>
int Array<T, N>::length() const
{
	return N;
}

template <typename T, int N>
bool Array<T, N>::set(int index, T value)
{
	bool ret = (0 <= index && N > index);
	if (ret)
	{
		mArray[index] = value;
	}
	return ret;
}

template <typename T, int N>
bool Array<T, N>::get(int index, T& value)
{
	bool ret = (0 <= index && N > index);
	if (ret)
	{
		value = mArray[index];
	}
	return ret;
}

template <typename T, int N>
T& Array<T, N>::operator[] (int index)
{
	if (0 <= index && N > index)
	{
		return mArray[index];
	}
		
	else
	{
		throw out_of_range("T& Array<T, N>::operator[] (int index)");
	}
}

template <typename T, int N>
T Array<T, N>::operator[] (int index) const
{
	if (0 <= index && N > index)
	{
		return mArray[index];
	}

	else
	{
		throw out_of_range("T Array<T, N>::operator[] (int index) const");
	}
}



#endif